//
//  RecreationDPViewController.m
//  PhoenixNews
//
//  Created by dllo on 16/1/18.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "RecreationDPViewController.h"
#import "PhoneixNews.pch"
#import "RecommentClickModel.h"
@interface RecreationDPViewController ()
@property (nonatomic, copy) NSString *string;
@property (nonatomic, retain) NSMutableDictionary *dic;
@end

@implementation RecreationDPViewController
- (void)dealloc {
    [_UrlStr release];
    [super dealloc];
    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
     self.title = @"凤凰浏览器";
    // 接收传过来的网址
    self.string = self.UrlStr;
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"block"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStylePlain target:self action:@selector(backButton:)];
    

    [self getData];
}
// 推荐详情页数据解析
#pragma 数据解析

- (void)getData {
     AFHTTPSessionManager *sessionManager = [AFHTTPSessionManager manager];
    [sessionManager GET:self.string parameters:nil progress:^(NSProgress * _Nonnull downloadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
       self.dic = responseObject[@"body"];
        RecommentClickModel *recomment = [RecommentClickModel modelWithDic:self.dic];
        NSURL *url = [NSURL URLWithString:recomment.shareurl];
        NSURLRequest *request = [NSURLRequest requestWithURL:url];
        UIWebView *web = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
        web.backgroundColor = [UIColor whiteColor];
        [web loadRequest:request];
        web.scalesPageToFit = YES;
        [self.view addSubview:web];
        [web release];
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        
    }];
}
- (void)backButton:(UIButton *)sender {
    [self.navigationController popToRootViewControllerAnimated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
